package com.sskj.functions.presenter;

import android.graphics.pdf.PdfDocument;

import com.lzy.okgo.model.Response;
import com.sskj.common.base.HttpData;
import com.sskj.common.util.MD5Util;
import com.sskj.functions.activity.StrategyInvestActivity;
import com.sskj.functions.presenter.BasePresenter;
import com.sskj.lib.bean.StrategyBean;
import com.sskj.lib.bean.UsableBean;
import com.sskj.lib.http.JsonCallBack;


/**
 * @author Hey
 * Create at  2019/07/10
 */
public class StrategyInvestPresenter extends BasePresenter<StrategyInvestActivity> {
    public void getBorrowData(String pay_type, String page, String type, String languages, boolean flag) {
        httpService.getStrategyData(pay_type, type, page, languages)
                .tag(this)
                .execute(new JsonCallBack<HttpData<StrategyBean>>(flag ? this : null) {
                    @Override
                    public void onSuccess(Response<HttpData<StrategyBean>> response) {
                        StrategyBean data = response.body().getData();
                        mView.getStrategyDataSuccess(data);
                    }
                });
    }

    public void startInvest(String toString, String id, String tv) {
        httpService.startInvest(toString, id, MD5Util.getFiveMd5Value(tv))
                .tag(this)
                .execute(new JsonCallBack<HttpData>() {
                    @Override
                    public void onSuccess(Response<HttpData> response) {
                        mView.InvestSuccess();
                    }
                });
    }


    public void getUsable(String id) {
        httpService.getUsable(id)
                .tag(this)
                .execute(new JsonCallBack<HttpData<UsableBean>>() {
                    @Override
                    public void onSuccess(Response<HttpData<UsableBean>> response) {
                        mView.getUsableOK(response.body().getData());
                    }
                });
    }

}
